<template>
  <div>
    <van-nav-bar
      title="个人资料"
      left-arrow
      right-text="修改"
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <!-- 基本信息 -->
    <van-cell-group>
      <van-cell title="昵称" :value="this.msg.nickName" />
      <van-cell title="性别" :value="this.msg.sex" />
      <van-cell title="生日" :value='this.msg.birthday' />
      <van-cell title="地区" :value='this.msg.addr' />
      <van-cell title="身份" :value='this.msg.card' />
    </van-cell-group>
    <van-button @click='loginout' class="tc" type="info" size="large">退出登录</van-button>

  </div>
</template>

<script>
  import * as get from '@/yoona/getProList.js'
  export default {
    name:'MyMsg',
    data(){
      return {
        active:0,
        msg:{},
      }
    },
    methods:{
      onClickLeft(){
        this.$router.back(-1)
      },
      onClickRight(){
        this.$router.push('/msgSetting')
      },
      loginout(){
        this.$router.push('/login')
      }
    },
    mounted(){
      let username = this.$store.state.message.username;
      if(username.length!=0){
        get.getUserMsg({
          username
        }).then(res=>{
          if(res.data.code == 1 && res.data.data.length>0){
            this.msg = res.data.data[0];
          }else{
            this.message = {
              nickName:'无',
              sex:'无',
              birthday:'无',
              addr:'无',
              card:'无'
            }
          }
        })
      }else{
        this.message = {
          nickName:'无',
          sex:'无',
          birthday:'无',
          addr:'无',
          card:'无'
        }
      }

    }
  }
</script>

<style scoped>
  .van-cell__title{
    text-align: left;
  }
  .tc{
    margin-top: 10px;
    background: #fff;
    color: black;
    border: 0;
  }
</style>
